package com.goushu.mapper;

import com.goushu.pojo.Book;
import com.goushu.pojo.Comment;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface BookMapper {

    @Select("select * from book order by sales desc limit 0, 10;")
    List<Book> listMain();

    @Select("select * from book where id = #{id}")
    Book listDetail(Integer id);

    @Select("select c.nickname, c.user_pic, b.detail, b.create_time from book_comment b join customer c on c_id=c.id where b_id = #{id}")
    List<Comment> listComment(Integer id);

    @Select("select * from book where name like concat('%', #{keyword}, '%') or author like concat('%', #{keyword}, '%')")
    List<Book> search(String keyword);

    @Select("select * from book where category=#{keyword}")
    List<Book> category(String keyword);
}
